<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <ul class="oUl">

    </ul>
    <script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
    <script>
        $.ajax({
            url: 'http://apis.juhe.cn/goodbook/catalog',
            dataType: 'jsonp',
            data: {
                key: '29884c49fe461c678f6deecc80adea20'
            },
            success(res) {
                let str = '';
                res.result.forEach(item => {
                    str += `<li>
                        <h3 vid=${item.id}>${item.catalog}</h3>
                        <ul class='content'></ul>
                        </li>`;
                })
                $('.oUl').html(str);
            }
        })

        $('.oUl').on('click', 'h3', function () {
            let _this = $(this);
            $.ajax({
                url: 'http://apis.juhe.cn/goodbook/query',
                dataType: 'jsonp',
                data: {
                    key: '29884c49fe461c678f6deecc80adea20',
                    catalog_id: $(this).attr('vid'),
                    pn: 1,
                    rn: 10
                },
                success(res) {
                    res.result.data.forEach(item => {
                        _this.parent().find('.content').append(`<p>${item.title}</p>`);
                    })
                }
            })
        })

    </script>
</body>

</html>